// strncmp模拟实现

#include <iostream>
#include <cassert>

int strncmp_self(const char* s1, const char* s2, size_t num)
{
    assert(s1 && s2);
    if(num == 0) return 0;
    while(--num && *s1 && (*s1 == *s2))
    {
        ++s1;
        ++s2;
    }
    return *s1 - *s2;
}


int main()
{
    const char* s1 = "bedfec";
    const char* s2 = "bedged";
    if(strncmp_self(s1, s2, 6) > 0)
    {
        std::cout << "s1 > s2" << std::endl;
    }
    else if(strncmp_self(s1, s2, 6) == 0)
    {
        std::cout << "s1 == s2" << std::endl;
    }
    else
    {
        std::cout << "s1 < s2" << std::endl;
    }
    return 0;
}